<?php
if($_GET['index']){
    $currentPage=$_GET['index'];
}else{
    $currentPage=1;
}
//$a=rtrim(shell_exec('python /www/wwwroot/gdmovie.guadou.cyou/6v/getIP.py'));
$indexdata=file_get_contents("http://localhost/api/pyToapi.php?page=index&index=$currentPage");
//echo json_encode($indexdata,false);
$data=json_decode($indexdata,false);
$code=$data->code;
$result=json_decode(json_encode($data->result),true);
//先encode再decode可以把object变成array
?>
<!doctype html>
<html lang="zh-Han">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>瓜豆影院-极新电影的聚集地</title>
    <link rel="stylesheet" href="index.css">
</head>
<body role="application">
    <div class="topview">
        <div class="searchbox"></div>
        <div class="moviebox">
            <div class="title">
                <text>瓜豆影院</text>
            </div>
            <div class="movietap">
                <?php
                for($i=0;$i<count($result);$i++){
                    echo "<a class='movieitem_box' href='/detail.php?movieId={$result[$i]['url']}'>";
                    echo "<img src='".$result[$i]['img']."' alt='' class='v_img'>";
                    echo "<div class='v_title'><h5>".$result[$i]['title']."</h5></div>";
                    echo '</a>';
                } ?>
            </div>
        </div>
    </div>
    <div class="pageindex">
        <div class="footerpage">
            <a href="/index.php?index=1" target="_self" class="index1" style="display: <?php echo $currentPage==1?'none':'inline';?>">首页</a>
            <a href="/index.php?index=<?php echo $currentPage-1 ?>" target="_self" class="index1">上一页</a>
            <a href="/index.php?index=<?php echo $currentPage+1 ?>" target="_self" class="index1"><?php echo $currentPage+1 ?></a>
            <a href="/index.php?index=<?php echo $currentPage+2 ?>" target="_self" class="index1"><?php echo $currentPage+2 ?></a>
            <a href="/index.php?index=<?php echo $currentPage+3 ?>" target="_self" class="index1"><?php echo $currentPage+3 ?></a>
            <a href="/index.php?index=<?php echo $currentPage+1 ?>" target="_self" class="index1">下一页</a>
        </div>
    </div>
</body>
</html>